/*
 * @Description:
 *  
 * @Date: 2021-05-11 09:51:36
 */
export const dateOptionsMixin = {
  data() {
    return {
      pickerOptions: {
        shortcuts: [
          {
            text: '今天',
            onClick(picker) {
              const start = new Date(new Date().toLocaleDateString()).getTime()
              const end = Date.now()
              picker.$emit('pick', [start, end])
            },
          },
          {
            text: '近7天',
            onClick(picker) {
              const end = new Date(new Date().toLocaleDateString()).getTime() - 1000
              const start = end - 864e5 * 7 + 1000
              picker.$emit('pick', [start, end])
            },
          },
          {
            text: '近90天',
            onClick(picker) {
              const end = new Date(new Date().toLocaleDateString()).getTime() - 1000
              const start = end - 864e5 * 90 + 1000
              picker.$emit('pick', [start, end])
            },
          },
        ],
        disabledDate(now) {
          const end = new Date(new Date().toLocaleDateString()).getTime() + 864e5 - 1000
          const start = end - 864e5 * 91 + 1000
          return now.getTime() < start || now.getTime() > end
        },
      },
    }
  },
}
